//
// catGL - Cheap Action-game Tool with WebGL.
//
// Copyright 2010, tmasda.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

function LightManager(){};

LightManager.prototype.setAmbLightColor = function(color){
    this.ambLightColor[0] = color[0];
    this.ambLightColor[1] = color[1];
    this.ambLightColor[2] = color[2];
}

LightManager.prototype.setDirLightDiffColor = function(color){
    this.dirLightDiffColor[0] = color[0];
    this.dirLightDiffColor[1] = color[1];
    this.dirLightDiffColor[2] = color[2];
}

LightManager.prototype.setDirLightSpecColor = function(color){
    this.dirLightSpecColor[0] = color[0];
    this.dirLightSpecColor[1] = color[1];
    this.dirLightSpecColor[2] = color[2];
}

LightManager.prototype.setDirLightVect = function(vect){
    vec3.normalize(vect, this.dirLightVect);
    //vec3.scale(this.dirLightVect, -1);
}

LightManager.create = function(){
    var lightMan = new LightManager();
    lightMan.ambLightColor = vec3.create([0.3, 0.3, 0.3]);
    lightMan.dirLightDiffColor = vec3.create([0.7, 0.7, 0.7]);
    lightMan.dirLightSpecColor = vec3.create([0.7, 0.7, 0.7]);
    // 平行光の向き（shaderでの利用を考えて反転して持つ）
    lightMan.dirLightVect = vec3.create();
    lightMan.setDirLightVect([0, 0, 1]);

    return lightMan;
}
